import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { UserRolesService } from './user-roles.service';
import { CreateUserRoleDto } from './dto/create-user-role.dto';
import { UpdateUserRoleDto } from './dto/update-user-role.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('用户角色')
@Controller('user-roles')
export class UserRolesController {
  constructor(private readonly userRolesService: UserRolesService) {}

  @ApiOperation({ summary: '创建用户角色' })
  @Post('create')
  create(@Body() createUserRoleDto: CreateUserRoleDto) {
    return this.userRolesService.create(createUserRoleDto);
  }

  @ApiOperation({ summary: '查询所有用户角色' })
  @Get('queryAll')
  findAll() {
    return this.userRolesService.findAll();
  }

  @ApiOperation({ summary: '查询用户角色' })
  @Get('query/:id')
  findOne(@Param('id') id: string) {
    return this.userRolesService.findOne(+id);
  }

  @ApiOperation({ summary: '编辑用户角色' })
  @Post('update/:id')
  update(
    @Param('id') id: string,
    @Body() updateUserRoleDto: UpdateUserRoleDto,
  ) {
    return this.userRolesService.update(+id, updateUserRoleDto);
  }

  @ApiOperation({ summary: '删除用户角色' })
  @Post('remove/:id')
  remove(@Param('id') id: string) {
    return this.userRolesService.remove(+id);
  }
}
